package core

import (
	"fmt"
	"gitee.com/lvshicong/blog/conf"
	"gitee.com/lvshicong/blog/flags"
	"gopkg.in/yaml.v3"
	"os"
)

//var confPath = "settings.yaml"

func ReadConf() (c *conf.Config) {
	// read config file
	file, err := os.ReadFile(flags.FlagsOptions.ConfPath)
	if err != nil {
		panic(err)
	}
	c = new(conf.Config)
	err = yaml.Unmarshal(file, &c)
	if err != nil {
		panic(fmt.Sprintf("yaml配置文件格式错误: %v\n", err))
	}

	fmt.Printf("成功读取配置文件: %s\n", flags.FlagsOptions.ConfPath)
	return
}
